package exactSearch;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;


public class Frequency {
	public static void main(String[]args) throws IOException{
		HashMap<String, Integer> hm=new LinkedHashMap<String, Integer>();
		PrintStream ps=new PrintStream("J:\\BC3_IMT_Training\\frequency.txt");
		FileReader fr=new FileReader("J:\\BC3_IMT_Training\\found.txt");
		BufferedReader fbr=new BufferedReader(fr);
		String str=fbr.readLine();

		int c=0;
		while(str!=null){
			if(hm.containsKey(str)==false){
				
				hm.put(str, 1);
				c=1;
			}
			else{
				c=hm.get(str);
				c++;
				hm.put(str, c);
			}
			
			str=fbr.readLine();
		}
		
		for (Iterator<String> itr = hm.keySet().iterator(); itr.hasNext();) {

			String next = itr.next();
			
			ps.println(next+" "+hm.get(next));
			
		}
		
	}
}
